<template>
	<view>
		<button @click="loginIn">登录</button>
	</view>
</template>

<script>
export default {
	data() {
		return {

		}
	},
	methods: {
		loginIn() {
			uni.getUserProfile({
				desc: '登录',
				success(res) {
					console.log(res)
					uni.login({
						success(res) {
							console.log(res);
							let code = res.code
							uni.request({
								method: "GET",
								url: `https://api.weixin.qq.com/sns/jscode2session?appid=wxcf99c2cc33592b1f&secret=459eebd548125ac2967f3982fe6d7571&js_code=${code}&grant_type=authorization_code`
							}).then(res => {
								console.log(res);
								uni.setStorageSync('openid', res.data.openid)
							})
						}
					})
				}
			})
		}
	}
}
</script>

<style></style>
